package com.fan.txl.data.auth;

import android.databinding.BaseObservable;
import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.annotation.JSONField;


/**
 * Created by jiajiabao on 17-1-10.
 */

public class Auth  extends BaseObservable implements Parcelable {


    private long accountId;
    private String accessToken;
    private long expiresIn;
    private TokenType tokenType;
    private Scope scope;
    private String refreshToken;

    public long getAccountId() {
        return accountId;
    }

    public void setAccountId(long accountId) {
        this.accountId = accountId;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public long getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(long expiresIn) {
        this.expiresIn = expiresIn;
    }

    public TokenType getTokenType() {
        return tokenType;
    }

    public void setTokenType(TokenType tokenType) {
        this.tokenType = tokenType;
    }

    public Scope getScope() {
        return scope;
    }

    public void setScope(Scope scope) {
        this.scope = scope;
    }

    public String getRefreshToken() {
        return refreshToken;
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.accountId);
        dest.writeString(this.accessToken);
        dest.writeLong(this.expiresIn);
        dest.writeInt(this.tokenType == null ? -1 : this.tokenType.ordinal());
        dest.writeInt(this.scope == null ? -1 : this.scope.ordinal());
        dest.writeString(this.refreshToken);
    }

    public Auth() {
    }

    protected Auth(Parcel in) {
        this.accountId = in.readLong();
        this.accessToken = in.readString();
        this.expiresIn = in.readLong();
        int tmpTokenType = in.readInt();
        this.tokenType = tmpTokenType == -1 ? null : TokenType.values()[tmpTokenType];
        int tmpScope = in.readInt();
        this.scope = tmpScope == -1 ? null : Scope.values()[tmpScope];
        this.refreshToken = in.readString();
    }

    public static final Creator<Auth> CREATOR = new Creator<Auth>() {
        @Override
        public Auth createFromParcel(Parcel source) {
            return new Auth(source);
        }

        @Override
        public Auth[] newArray(int size) {
            return new Auth[size];
        }
    };
}
